using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class RecurringPaymentHistoryMap : EntityTypeConfiguration<RecurringPaymentHistory>
    {
        public RecurringPaymentHistoryMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("RecurringPaymentHistory");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.RecurringPaymentId).HasColumnName("RecurringPaymentId");
            this.Property(t => t.OrderId).HasColumnName("OrderId");
            this.Property(t => t.CreatedOnUtc).HasColumnName("CreatedOnUtc");

            // Relationships
            this.HasRequired(t => t.RecurringPayment)
                .WithMany(t => t.RecurringPaymentHistories)
                .HasForeignKey(d => d.RecurringPaymentId);

        }
    }
}
